package jblip.util.json;

import java.math.BigDecimal;
import java.util.regex.Pattern;

public class JSONNumber implements JSONValue<BigDecimal> {

  private static final Pattern JSONNUMBER = Pattern.compile(
      "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$");
  
  public static boolean isJSONCompilant(String str) {
    return JSONNUMBER.matcher(str).matches();
  }
  
  private final BigDecimal value;
  
  public JSONNumber(String value) {
    this.value = new BigDecimal(value);
  }
  
  public BigDecimal getValue() {
    return value;
  }
}
